<?php

class MyController extends Controllers {

    function __construct($aryConfigs, $aryConfigDB) {
        parent::__construct();
        $this->assign('root_page', $this->getRootPage());
        $this->assign('sub_domain', $this->getSubDomain());
        $this->_objConfig = $aryConfigs;
        $this->_objModule = new MyModules($aryConfigDB);
    }

    function __destruct() {
        if ($this->getParam('ajax') != 1) {
//            $this->setFooter();
        }
    }

    public function def() {

        $aryCss = array();
        $aryCss[] = "main.min.css";
        $this->getRightProduct();
        $this->getHomeKeyword();
        $this->getSlider();
        $this->getBaogia();

        $aryRootCategory = $this->buildMenu();
        $this->buildHomeProduct($aryRootCategory);
        $this->assign('aryCss', $aryCss);
//        $this->assign('aryJs', $aryJs);
        $subDomain = $this->getSubDomain();
        $this->assign('urlImage', $subDomain['img'] . '/images/style/logo120x120.jpg');
        $this->assign('urlLink', $this->curUrl());
        $aryConfig = $this->getDataConfigFile('home_data_store');
        $this->assign('title', $aryConfig['common_home_title']);
        $this->assign('keywords', $aryConfig['common_home_keyword']);
        $this->assign('description', $aryConfig['common_home_description']);
        $this->setViewTemplate('home', 'home');
    }

    public function getHomeKeyword() {
        $aryHomeKeyword = $this->getDataFromSqlCache('home_data_store');
        $this->assign('title', $aryHomeKeyword['common_home_title']);
        $this->assign('keywords', $aryHomeKeyword['common_home_keyword']);
        $this->assign('description', $aryHomeKeyword['common_home_description']);
    }

    public function getTopProduct() {

        $aryTopProduct = array();

        $flag = $this->getDataFromSqlCache('flag_cache_home_product');

        $flagCache = $flag[0];
        //neu khong co su san pham moi tu trang quan tri
        if ($flagCache == 0 && $this->checkSqlCacheFile('cache_home_product') == true) {

            $aryTopProduct = $this->getDataFromSqlCache('cache_home_product');
        } else if ($flagCache == 1 || $this->checkSqlCacheFile('cache_home_product') == false) {

            $aryConfig = $this->getDataConfigFile('config_product_page');

            $limit = $aryConfig['config_product_in_home'];

            $this->_objModule->getTopProduct(2, $limit, $aryTopProduct);

            $aryFlag = array('0' => 0);

            $this->buildSqlCache('flag_cache_home_product', $aryFlag);

            $this->buildSqlCache('cache_home_product', $aryTopProduct);
        }

        $this->assign('aryTopProduct', $aryTopProduct);
    }

    public function getRightProduct() {

        $aryRightProduct = array();

        $flagFile = 'flag_cache_right_product';

        $caceFile = 'cache_right_product';

        $flag = $this->getDataFromSqlCache($flagFile);

        $flagCache = $flag[0];

        if ($flagCache == 0 && $this->checkSqlCacheFile($caceFile) == true) {

            $aryRightProduct = $this->getDataFromSqlCache($caceFile);
        } else if ($flagCache == 1 || $this->checkSqlCacheFile($caceFile) == false) {

            $aryConfig = $this->getDataConfigFile('home_data_store');

            $limit = $aryConfig['config_product_in_right'];

            $intOk = $this->_objModule->getTopProduct(1, $limit, $aryRightProduct);

            if ($intOk == 1) {

                $this->buildSqlCache($caceFile, $aryRightProduct);

                $this->resetFlagCacheFile($flagFile);
            }
        }

        $this->assign('aryRightProduct', $aryRightProduct);
    }

    public function getListProductViewed() {
        $listProduct = $this->getCookieData('list_product');
        if (strlen($listProduct) > 0) {
            $aryListProduct = explode(",", $listProduct);
            $total = count($aryListProduct);
            unset($aryListProduct[$total - 1]);
            $listProductid = implode(",", $aryListProduct);
            $this->_objModule->getProducyByListId($listProductid, $aryProduct);
            $aryData = array();
            foreach ($aryListProduct as $key => $value) {
                for ($n = 0; $n < $total; $n++) {
                    if ($aryProduct[$n]['product_id'] == $value) {
                        $aryData[$key] = $aryProduct[$n];
                    }
                }
            }
        }
        $this->assign('productViewed', $aryData);
    }

    public function buildHomeProduct($aryRootCategory) {

        $aryProduct = array();

        $flag = $this->getDataFromSqlCache('flag_cache_home_product');

        $flagCache = $flag[0];
        //neu khong co su san pham moi tu trang quan tri
        if ($flagCache == 0 && $this->checkSqlCacheFile('cache_home_product_by_category') == true) {

            $aryProduct = $this->getDataFromSqlCache('cache_home_product_by_category');
        } else if ($flagCache == 1 || $this->checkSqlCacheFile('cache_home_product_by_category') == false) {

            foreach ($aryRootCategory as $key => $value) {

                if ($value['category_is_show'] == 1) {

                    $aryCategoryId[] = $value['category_id'];
                }
            }
            foreach ($aryCategoryId as $key => $value) {

                $ary[] = $this->_objModule->getCategoryChildPath($value, true);

                if (count($ary[$key]) > 0) {

                    $strCategory = implode(',', $ary[$key]);
                } else {

                    $strCategory = $value;
                }

                $aryConfig = $this->getDataConfigFile('home_data_store');

                $limit = $aryConfig['config_product_in_home'];

                $intOk = $this->_objModule->getProductByListCatId($strCategory, $limit, $aryProduct[$value]);
            }
            if ($intOk == 1) {
                $aryFlag = array('0' => 0);

                $this->buildSqlCache('flag_cache_home_product', $aryFlag);

                $this->buildSqlCache('cache_home_product_by_category', $aryProduct);
            }
        }
        $this->assign('aryProduct', $aryProduct);
    }

    public function buildMenu() {

        $aryRootCategory = array();

        $arySubCategory = array();

        $arySubCategoryLevel2 = array();

        if ($this->checkSqlCacheFile('root_category') && $this->getFlagRootCategoryCache() == 0) {

            $aryRootCategory = $this->getDataFromSqlCache('root_category');

            $arySubCategory = $this->getDataFromSqlCache('sub_category_level_1');

            $arySubCategoryLevel2 = $this->getDataFromSqlCache('sub_category_level_2');

            $aryProductCategory = $this->getDataFromSqlCache('root_all_category');
            
        } else if ($this->checkSqlCacheFile('root_category') == false || $this->getFlagRootCategoryCache() == 1) {

            $intOk = $this->_objModule->getProductCategory($aryProductCategory);

            foreach ($aryProductCategory as $key => $value) {
                if ($value['category_parent'] == 0) {
                    $aryRootCategory[$key]['category_id'] = $value['category_id'];
                    $aryRootCategory[$key]['category_name'] = $value['category_name'];
                    $aryRootCategory[$key]['category_name_filter'] = $value['category_name_filter'];
                    $aryRootCategory[$key]['category_main_image'] = $value['category_main_image'];
                    $aryRootCategory[$key]['category_small_image'] = $value['category_small_image'];
                    $aryRootCategory[$key]['category_large_image'] = $value['category_large_image'];
                    $aryRootCategory[$key]['category_total_child'] = $value['category_total_child'];
                    $aryRootCategory[$key]['category_is_show'] = $value['category_is_show'];
//                $arySubCategory[$value['category_id']]['parent_id'] = $value['category_id'];
                }
            }
            foreach ($aryRootCategory as $key => $value) {
                foreach ($aryProductCategory as $key2 => $value2) {
                    if ($value['category_id'] == $value2['category_parent']) {
                        $arySubCategory[$value2['category_id']]['parent_id'] = $value['category_id'];
                        $arySubCategory[$value2['category_id']]['category_id'] = $value2['category_id'];
                        $arySubCategory[$value2['category_id']]['category_name'] = $value2['category_name'];
                        $arySubCategory[$value2['category_id']]['category_main_image'] = $value2['category_main_image'];
                        $arySubCategory[$value2['category_id']]['category_small_image'] = $value2['category_small_image'];
                        $arySubCategory[$value2['category_id']]['category_large_image'] = $value2['category_large_image'];
                        $arySubCategory[$value2['category_id']]['category_name_filter'] = $value2['category_name_filter'];
                        $arySubCategory[$value2['category_id']]['category_total_child'] = $value2['category_total_child'];
                        $arySubCategory[$value2['category_id']]['category_is_show'] = $value2['category_is_show'];
                    }
                }
            }

            foreach ($arySubCategory as $key => $value) {
                foreach ($aryProductCategory as $key2 => $value2) {
                    if ($value['category_id'] == $value2['category_parent']) {
                        $arySubCategoryLevel2[$value2['category_id']]['parent_id'] = $value['category_id'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_id'] = $value2['category_id'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_name'] = $value2['category_name'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_main_image'] = $value2['category_main_image'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_small_image'] = $value2['category_small_image'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_large_image'] = $value2['category_large_image'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_name_filter'] = $value2['category_name_filter'];
                        $arySubCategoryLevel2[$value2['category_id']]['category_total_child'] = $value2['category_total_child'];
                    }
                }
            }
            if ($intOk == 1) {
                $this->buildSqlCache('root_all_category', $aryProductCategory);
                $this->buildSqlCache('root_category', $aryRootCategory);
                $this->buildSqlCache('sub_category_level_1', $arySubCategory);
                $this->buildSqlCache('sub_category_level_2', $arySubCategoryLevel2);
                $this->resetFlagRootCategoryCache();
            }
        }
        $this->assign('aryRootCategory', $aryRootCategory);
        $this->assign('arySubCategory', $arySubCategory);
        $this->assign('arySubCategoryLevel2', $arySubCategoryLevel2);
        return $aryRootCategory;
    }

    public function buildRightItem($listCategory = null, $flagCache = null) {

        $aryProuductType = $this->getConfig('product_type');

        $aryProductByType = array();

        $ext = str_replace(",", "", $listCategory);

        if (isset($flagCache) && $flagCache == 1) {

            foreach ($aryProuductType as $key => $value) {

                $this->_objModule->getProductByType($key, $aryProductByType[$key], $listCategory);
            }

            $this->buildSqlCache('product_by_type_cat_' . $ext, $aryProductByType);
        } else {

            $aryProductByType = $this->getDataFromSqlCache('product_by_type_cat_' . $ext);

            echo 'product type lay tu file cache';
        }



        $this->assign('aryProductByType', $aryProductByType);

        $this->assign('aryProductType', $aryProuductType);
    }

    public function sanpham() {

        $productId = $this->getParamOnUrlByKey(1);

        $this->filterVarId($productId);

        $aryCss = array();

        $aryCss[] = "main.min.css";

        $this->getSlider();

        $this->buildMenu();

        $this->getRightProduct();

        $this->getBaogia();

        $flagProductDetailCache = $this->getFlagProductDetailCache($productId);

        if ($flagProductDetailCache == 1 || $this->checkSqlCacheFile('product_detail_' . $productId) == false) {

            $intOk = $this->_objModule->getProductById($productId, $aryProductDetail);

            $this->buildSqlCache('product_detail_' . $productId, $aryProductDetail);
        } else if ($flagProductDetailCache == 0 && $this->checkSqlCacheFile('product_detail_' . $productId) == true) {

            $aryProductDetail = $this->getDataFromSqlCache('product_detail_' . $productId);
        }

        $intOk = $this->_objModule->getProductComments($productId, $aryComments);

        $categoryId = $aryProductDetail[0]['product_category_id'];

        $flagCacheCategory = $this->getFlagCategoryCache($categoryId);

        if ($flagCacheCategory == 1 || $this->checkSqlCacheFile('category_' . $categoryId . '_parent') == false) {

            $aryCategoryParent = $this->buildParentList($categoryId);
        } else if ($flagCacheCategory == 0 && $this->checkSqlCacheFile('category_' . $categoryId . '_parent') == true) {

            $aryCategoryParent = $this->getDataFromSqlCache('category_' . $categoryId . '_parent');
        }

        foreach ($aryCategoryParent as $key => $value) {

            $categoryContent = $value['category_content'];
        }

        $this->assign('categoryContent', $categoryContent);

        $this->assign('categoryParent', $aryCategoryParent);

        $aryConditions = array();

        $aryConditions['list_category'] = $categoryId;

        $aryConditions['current_page'] = 1;

        $aryConfig = $this->getDataConfigFile('home_data_store');

        $limit = $aryConfig['config_product_in_detail'];

        $aryConditions['record_per_page'] = $limit;

        $aryConditions['has_child_category'] = 0;

        foreach ($aryConditions as $key => $value) {

            if ($key != 'list_product_id') {
                $cacheProductFile .= $value;
            }
        }

        $cacheProductFile = str_replace(",", "", $cacheProductFile);

        $cacheProductFile = 'product' . $cacheProductFile;

        if ($this->getFlagProductCache($categoryId) == 1 || $this->checkSqlCacheFile($cacheProductFile) == false) {

            $this->_objModule->getProduct($aryConditions, $aryProduct, $aryProductConditions);

            $this->buildSqlCache($cacheProductFile, $aryProduct);
        } else if ($this->getFlagProductCache($categoryId) == 0 && $this->checkSqlCacheFile($cacheProductFile) == true) {

            $aryProduct = $this->getDataFromSqlCache($cacheProductFile);
        }

        $this->resetFlagProductDetailCache($productId);

        $this->assign('product_limit', $aryConfig['config_product_in_detail']);

        $this->assign('aryCss', $aryCss);
        $this->assign('aryJs', $aryJs);

        $strTitle = $aryProductDetail[0]['product_search_title'];
        $strKeyword = $aryProductDetail[0]['product_search_keyword'];
        $strDescription = $aryProductDetail[0]['product_search_description'];
        $subDomain = $this->getSubDomain();
        $this->assign('urlImage', $subDomain['img'] . '/images/upload/thumbnail/' . $aryProductDetail[0]['product_main_image']);
        $this->assign('urlLink', $this->curUrl());
        $this->assign('title', $strTitle);
        $this->assign('keywords', $strKeyword);
        $this->assign('description', $strDescription);
        $this->assign('aryProductDetail', $aryProductDetail[0]);
        $this->assign('aryProduct', $aryProduct['data']);
        $this->setViewTemplate('home', 'product_detail');
    }

    public function setProductViewed($productId) {
        if ($this->hasCookie('list_product')) {
            $listProductId = $this->getCookieData('list_product');
            $aryProductId = explode(',', $listProductId);
            if (in_array($productId, $aryProductId) === false) {
                $listProductId = $listProductId . $productId . ',';
                $this->setCookieData('list_product', $listProductId);
            }
        } else {
            $this->setCookieData('list_product', $productId . ',');
        }
    }

    public function listSupportOnline() {
        $this->assign('arySupport', $this->getConfig('support_online'));
    }

    public function buildParentList($categoryId) {

        $aryCategory = $this->getDataFromSqlCache('root_all_category');

        $aryCategoryParent = $this->findCategoryParentPath($aryCategory, $categoryId);

        $this->buildSqlCache('category_' . $categoryId . '_parent', $aryCategoryParent);

        return $aryCategoryParent;
    }

    public function buildChildList($categoryId) {
        $aryCategory = $this->getDataFromSqlCache('root_all_category');
        $aryChildId = $this->findCategoryChildPathId($aryCategory, $categoryId);
        $this->buildSqlCache('category_' . $categoryId . '_child_list', $aryChildId);
        return $aryChildId;
    }

    public function findCategoryParentPath($aryCategory, $categoryId) {
        $aryParent = array();
        foreach ($aryCategory as $value) {
            if ($value['category_id'] == $categoryId) {
                if ($value['category_parent'] != 0) {
                    $aryParent[] = $value;
                    $aryParent = array_merge($this->findCategoryParentPath($aryCategory, $value['category_parent']), $aryParent);
                } else {
                    $aryParent[] = $value;
                }
            }
        }
        return $aryParent;
    }

    public function findCategoryChildPathId($aryCategory, $categoryId) {
        $aryChildId = array();
        foreach ($aryCategory as $key => $value) {
            if ($value['category_parent'] == $categoryId) {
                $aryChildId[] = $value['category_id'];
                $aryChildId = array_merge($this->findCategoryChildPathId($aryCategory, $value['category_id']), $aryChildId);
            }
        }
        return $aryChildId;
    }

    public function getProductOrder() {

        $this->getSessionCustomer();

        $cookieShopCat = $this->getCookieData('globe_shopcat');

        $inOk = $this->_objModule->getProductOrderByCookie($cookieShopCat, $aryProductOrder);

        $this->_objModule->getProductOrderDetail($cookieShopCat, $aryProductOrderDetail);

        $this->assign('aryProductOrderDetail', $aryProductOrderDetail[0]);

        $aryOrderProductId = array();

        $totalPrice = 0;

        foreach ($aryProductOrder as $key => $value) {

            $aryOrderProductId[] = $value['product_order_product_id'];

            $totalPrice = $totalPrice + $value['product_order_total_price'];

            $aryProduct[$key]['product_order_id'] = $value['product_order_id'];
            $aryProduct[$key]['product_order_product_id'] = $value['product_order_product_id'];
            $aryProduct[$key]['product_order_product_name'] = $value['product_order_product_name'];
            $aryProduct[$key]['product_order_product_filter_name'] = $this->filterUnicode($value['product_order_product_name']);
            $aryProduct[$key]['product_order_total_product'] = $value['product_order_total_product'];
            $aryProduct[$key]['product_order_product_price'] = $value['product_order_product_price'];
            $aryProduct[$key]['product_order_total_price'] = $value['product_order_total_price'];
            $aryProduct[$key]['product_order_active'] = $value['product_order_active'];
            $aryProduct[$key]['product_order_product_image'] = $value['product_order_product_image'];
            $aryProduct[$key]['product_order_category_id'] = $value['product_order_category_id'];
            $aryProduct[$key]['product_order_category_name'] = $value['product_order_category_name'];
            $aryProduct[$key]['product_order_category_filter'] = $value['product_order_category_filter'];
        }

        $this->assign('aryOrderProductId', $aryOrderProductId);

        $this->assign('aryProductOrder', $aryProduct);

        $this->assign('totalPrice', $totalPrice);
    }

    public function danhmuc() {

        $categoryId = $this->getParamOnUrlByKey(1);

        $this->filterVarId($categoryId);

        $aryCss = array();
        $aryCss[] = "main.min.css";

        $this->getSlider();

        $this->buildMenu();

        $this->getRightProduct();

        $this->getBaogia();
        
        $flagCache = $this->getFlagCategoryCache($categoryId);

        if ($flagCache == 1 || $this->checkSqlCacheFile('category_' . $categoryId . '_sub') == false) {

            $aryCategory = $this->getDataFromSqlCache('root_all_category');

            $arySubCategory = array();
            foreach ($aryCategory as $category) {
                if ($category['category_parent'] == $categoryId) {
                    $arySubCategory[] = $category;
                }
            }
            $this->buildSqlCache('category_' . $categoryId . '_sub', $arySubCategory);
            
        } else if ($flagCache == 0 && $this->checkSqlCacheFile('category_' . $categoryId . '_sub') == true) {

            $arySubCategory = $this->getDataFromSqlCache('category_' . $categoryId . '_sub');
        }

        if ($flagCache == 1 || $this->checkSqlCacheFile('category_' . $categoryId . '_parent') == false) {

            $aryCategoryParent = $this->buildParentList($categoryId);
            
        } else if ($flagCache == 0 && $this->checkSqlCacheFile('category_' . $categoryId . '_parent') == true) {

            $aryCategoryParent = $this->getDataFromSqlCache('category_' . $categoryId . '_parent');
        }

        $this->assign('categoryParent', $aryCategoryParent);

        if (isset($aryCategoryParent[0])) {

            foreach ($aryCategoryParent as $key => $value) {

                if ($value['category_title_header'] == '') {
                    $strTitle = $value['category_name'];
                } else {
                    $strTitle = $value['category_title_header'];
                }

                if ($value['category_keyword'] == '') {
                    $keywords = $value['category_name'];
                } else {
                    $keywords = $value['category_keyword'];
                }

                if ($value['category_description'] == '') {
                    $description = $value['category_name'];
                } else {
                    $description = $value['category_description'];
                }

                $categoryContent = $value['category_content'];

                if ($value['category_content_h1'] == '') {
                    $H1Content = $value['category_name'];
                } else {
                    $H1Content = $value['category_content_h1'];
                }
                $imageCategory = $value['category_main_image'];
                $categoryNameFilter = $value['category_name_filter'];
            }
        }

        $this->assign('categoryContent', $categoryContent);

        $this->assign('H1Content', $H1Content);

        if ($flagCache == 1 || $this->checkSqlCacheFile('category_' . $categoryId . '_child_list') == false) {

            $aryCategoryId = $this->buildChildList($categoryId);
//            $aryCategoryId = $this->_objModule->getCategoryChildPath($categoryId);
//            $this->buildSqlCache('category_' . $categoryId . '_child_list', $aryCategoryId);
        } else if ($flagCache == 0 && $this->checkSqlCacheFile('category_' . $categoryId . '_child_list') == true) {

            $aryCategoryId = $this->getDataFromSqlCache('category_' . $categoryId . '_child_list');
        }

        if (count($aryCategoryId) > 0) {

            $hasChildCategory = 1;

            array_push($aryCategoryId, $categoryId);

            $listCategoryId = implode(',', $aryCategoryId);
        } else {

            $hasChildCategory = 0;

            $listCategoryId = $categoryId;
        }

        $page = $this->getParam('page');

        if (!$page) {

            $page = 1;
        }

        $aryConditions = array();

        $aryConditions['list_category'] = $listCategoryId;

        $aryConditions['current_page'] = $page;

        $aryConfig = $this->getDataConfigFile('home_data_store');

        $limit = $aryConfig['config_product_in_product'];

        $aryConditions['record_per_page'] = $limit;

        $aryConditions['has_child_category'] = $hasChildCategory;

        foreach ($aryConditions as $key => $value) {

            if ($key != 'list_product_id') {
                $cacheProductFile .= $value;
            }
        }

        $cacheProductFile = str_replace(",", "", $cacheProductFile);

        $cacheProductFile = 'product' . $cacheProductFile;

        if ($this->getFlagProductCache($categoryId) == 1 || $this->checkSqlCacheFile($cacheProductFile) == false) {

            $intOk = $this->_objModule->getProduct($aryConditions, $aryProduct, $aryProductConditions);

            if ($intOk == 1) {

                $this->buildSqlCache($cacheProductFile, $aryProduct);
            }
        } else if ($this->getFlagProductCache($categoryId) == 0 && $this->checkSqlCacheFile($cacheProductFile) == true) {

            $aryProduct = $this->getDataFromSqlCache($cacheProductFile);
        }

        $link = $url . '?page=';

        $strPaging = $this->pagination($link, $aryProduct['paging']);

        //reset cache sau khi da cache
        if ($intOk == 1) {
            $this->resetFlagProductCache($categoryId);
            $this->resetFlagCategoryCache($categoryId);
        }
        $this->assign('aryCss', $aryCss);
        $this->assign('aryJs', $aryJs);
        $this->assign('categoryId', $categoryId);

        $this->assign('categoryNameFilter', $categoryNameFilter);

        $this->assign('aryProduct', $aryProduct['data']);

        $this->assign('aryCategory', $arySubCategory);

        $this->assign('hasChildCategory', $hasChildCategory);

        $this->assign('strPaging', $strPaging);

        $this->assign('keywords', $keywords);

        $this->assign('title', $strTitle);

        $this->assign('description', $description);

        $subDomain = $this->getSubDomain();

        $this->assign('urlImage', $subDomain['img'] . '/images/upload/thumbnail/' . $imageCategory);

        $this->assign('urlLink', $this->curUrl());

        $this->setViewTemplate('home', 'product_list_product');
    }

    public function sortArray($inputArray) {
        $arySort = array_keys($inputArray);
        asort($arySort, SORT_NUMERIC);
        foreach ($arySort as $key => $value) {
            $aryAfterSort[] = $inputArray[$value];
        }
        return $aryAfterSort;
    }

    public function order() {

        $this->getProductOrder();

        $this->buildMenu();

        $cookieShopCat = $this->getCookieData('globe_shopcat');

        $aryMethodDelivery = $this->getConfig('method_delivery');

        $aryMethodPayment = $this->getConfig('method_payment');

        $this->assign('aryMethodDelivery', $aryMethodDelivery);

        $this->assign('aryMethodPayment', $aryMethodPayment);

        $this->assign('title', 'Chi tiết giỏ hàng.');

        $this->setViewTemplate('home', 'product_order');
    }

    public function saveProductToShopCat() {

        $cookieShopCat = $this->getCookieData('globe_shopcat');

        $productId = $this->getPostParam('productId');

        $categoryId = $this->getPostParam('categoryId');


        $this->_objModule->checkExistOrder($productId, $cookieShopCat, $aryResultData);

        $existed = false;

        if (isset($aryResultData[0])) {

            $existed = true;

            $intOk = -2;
        }

        if ($existed == false) {

            $intOk = $this->_objModule->getProductPriceById($productId, $aryData);

            $intOk = $this->_objModule->getCategoryByListId($categoryId, $aryCategory);

            if ($aryData[0]['product_price_active_km'] == 1) {

                $productPrice = $aryData[0]['product_price_vnd_km'];
            } else {

                $productPrice = $aryData[0]['product_price_vnd'];
            }
            $aryOrderInsert = array();
            $aryOrderInsert['product_order_cookie_id'] = $cookieShopCat;
            $aryOrderInsert['product_order_product_id'] = $productId;
            $aryOrderInsert['product_order_product_name'] = $aryData[0]['product_title'];
            $aryOrderInsert['product_order_product_name_search'] = $this->encodingUnicode($aryData[0]['product_title']);
            $aryOrderInsert['product_order_product_name_filter'] = $this->filterUnicode($aryData[0]['product_title']);
            $aryOrderInsert['product_order_product_image'] = $aryData[0]['product_main_image'];
            $aryOrderInsert['product_order_total_product'] = 1;
            $aryOrderInsert['product_order_category_id'] = $aryCategory[0]['category_id'];
            $aryOrderInsert['product_order_category_name'] = $aryCategory[0]['category_name'];
            $aryOrderInsert['product_order_category_filter'] = $aryCategory[0]['category_name_filter'];
            $aryOrderInsert['product_order_total_price'] = $productPrice;
            $aryOrderInsert['product_order_product_price'] = $productPrice;
            $aryOrderInsert['product_order_product_price_in'] = $aryData[0]['product_price_vnd_in'];
            $aryOrderInsert['product_order_create_date'] = date('Y-m-d H:i:s');
            $aryOrderInsert['product_order_create_date_date'] = date('d');
            $aryOrderInsert['product_order_create_date_month'] = date('m');
            $aryOrderInsert['product_order_create_date_year'] = date('Y');

            $intOk = $this->_objModule->insertProductOrder($aryOrderInsert);
        }

        $this->getProductOrder();

        $this->assign('existed', $existed);

        $aryResult = array();
        $aryResult['intOk'] = $intOk;
        $aryResult['productId'] = $productId;
        $aryResult['strContent'] = $this->getViewTemplate('home', 'product_check_exist_order');
        $aryResult['myShopCat'] = $this->getViewTemplate('home', 'product_shop_content');
        echo json_encode($aryResult);
    }

    public function changeOrderItem() {
        $aryParam = $this->getAllPostParams();

        $orderId = $aryParam['orderId'];

        $numOfItem = $aryParam['item'];

        $price = $aryParam['price'];

        $aryOrderUpdate = array();

        $aryOrderUpdate['product_order_total_product'] = $numOfItem;

        $aryOrderUpdate['product_order_total_price'] = $numOfItem * $price;

        $aryConfig = array(
            array(
                'keyword' => 'where',
                'field' => 'product_order_id',
                'math' => '=',
                'value' => $orderId
            )
        );

        $inOk = $this->_objModule->updateTotalItem($aryOrderUpdate, $aryConfig);

        $intOk = $this->getProductOrder();

        $aryResult = array();
        $aryResult['intOk'] = $intOk;
        $aryResult['leftOrderContent'] = $this->getViewTemplate('home', 'product_shop_content');
        $aryResult['listOrder'] = $this->getViewTemplate('home', 'product_list_order');
        echo json_encode($aryResult);
    }

    public function saveOrderInfo() {

        $intOk = 1;

        $aryParam = $this->getAllPostParams();

        $aryError = $this->validateOrder($aryParam);

        if (count($aryError) > 0) {
            $intOk = -2;
        }

        if ($intOk == 1) {

            $cookieShopCat = $this->getCookieData('globe_shopcat');

            $aryMethodDelivery = $this->getConfig('method_delivery');

            $aryMethodPayment = $this->getConfig('method_payment');

            $this->assign('aryMethodDelivery', $aryMethodDelivery);

            $this->assign('aryMethodPayment', $aryMethodPayment);

            $aryOrderDetail = array();
            $aryOrderDetail['order_detail_cookie_id'] = $cookieShopCat;
            $aryOrderDetail['order_detail_full_name'] = $aryParam['order_full_name'];
            $aryOrderDetail['order_detail_search_name'] = $this->encodingUnicode($aryParam['order_full_name']);
            $aryOrderDetail['order_detail_address'] = $aryParam['order_address'];
            $aryOrderDetail['order_detail_phone_number'] = $aryParam['order_phone_number'];
            $aryOrderDetail['order_detail_email'] = $aryParam['order_email'];
            $aryOrderDetail['order_detail_address_delivery'] = $aryParam['order_address_delivery'];
            $aryOrderDetail['order_detail_method_delivery'] = $aryParam['method_delivery'];
            $aryOrderDetail['order_detail_delivery_name'] = $aryMethodDelivery[$aryParam['method_delivery']];
            $aryOrderDetail['order_detail_method_payment'] = $aryParam['method_payment'];
            $aryOrderDetail['order_detail_payment_name'] = $aryMethodPayment[$aryParam['method_payment']];
            $aryOrderDetail['order_detail_company_name'] = $aryParam['order_company_name'];
            $aryOrderDetail['order_detail_company_address'] = $aryParam['order_company_address'];
            $aryOrderDetail['order_detail_company_tax_code'] = $aryParam['order_company_tax_code'];
            $aryOrderDetail['order_detail_created_date'] = date('Y-m-d H:i:s');
            $aryOrderDetail['order_detail_created_date_date'] = date('d');
            $aryOrderDetail['order_detail_created_date_month'] = date('m');
            $aryOrderDetail['order_detail_created_date_year'] = date('Y');
            $this->_objModule->checkExistOrderDetail($cookieShopCat, $aryData);

            if (isset($aryData[0])) {

                $aryConfig = array(
                    array(
                        'keyword' => 'where',
                        'field' => 'order_detail_id',
                        'math' => '=',
                        'value' => $aryData[0]['order_detail_id']
                    )
                );

                $detailId = $aryData[0]['order_detail_id'];

                $intOk = $this->_objModule->updateProductOrderDetail($aryOrderDetail, $aryConfig);
            } else {

                $intOk = $this->_objModule->insertOrderDetail($aryOrderDetail, $returnOrderId);

                $detailId = $returnOrderId;
            }

            if ($intOk == 1) {

                $this->_objModule->updateOrder($detailId, $cookieShopCat);

                $this->getProductOrder();

                $this->assign('aryProductOrderDetail', $aryOrderDetail);
            }
        }

        $aryResult = array();
        $aryResult['intOk'] = $intOk;
        $aryResult['aryError'] = $aryError;
        $aryResult['messageError'] = _ORDER_MESSAGE_ERROR;
        $aryResult['shopContent'] = $this->getViewTemplate('home', 'product_order_bill');
        $aryResult['shopLeftContent'] = $this->getViewTemplate('home', 'product_shop_content');
        echo json_encode($aryResult);
    }

    public function validateOrder($aryParam) {
        $objValidator = new Validator();

        $aryError = array();

        $flag = $objValidator->validateEmpty($aryParam['order_full_name']);
        if ($flag == true) {
            $aryError['order_full_name_error'] = _ORDER_EMPTY_FULL_NAME;
        }
        $flag = $objValidator->validateEmpty($aryParam['order_address']);
        if ($flag == true) {
            $aryError['order_address_error'] = _ORDER_EMPTY_ADDRESS;
        }
        $flag = $objValidator->validateEmpty($aryParam['order_phone_number']);
        if ($flag == true) {
            $aryError['order_phone_number_error'] = _ORDER_EMPTY_PHONE_NUMBER;
        } else {
            $flag = $objValidator->validatePhone($aryParam['order_phone_number']);
            if ($flag == false) {
                $aryError['order_phone_number_error'] = _ORDER_ERROR_FORMAT_PHONE_NUMBER;
            }
        }
        $flag = $objValidator->validateEmpty($aryParam['order_email']);
        if ($flag == true) {
            $aryError['order_email_error'] = _ORDER_EMPTY_EMAIL;
        } else {
            $flag = $objValidator->validateMail($aryParam['order_email']);
            if ($flag == false) {
                $aryError['order_email_error'] = _ORDER_ERROR_FORMAT_MAIL;
            }
        }
        $flag = $objValidator->validateEmpty($aryParam['order_address_delivery']);
        if ($flag == true) {
            $aryError['order_address_delivery_error'] = _ORDER_EMPTY_ADDRESS_DELIVERY;
        }
        return $aryError;
    }

    public function activeOrder() {

        $cookieShopCat = $this->getCookieData('globe_shopcat');

        $intOk = $this->_objModule->activeOderDetail($cookieShopCat);

        if ($intOk == 1) {

            $this->clearCookie('globe_shopcat');

            $this->setCookieShopCat();
        }



        $aryResult = array();
        $aryResult['intOk'] = $intOk;
        $aryResult['url'] = $this->getRootPage();
        $aryResult['message'] = _ORDER_ACTIVE_SUCCESS;
        echo json_encode($aryResult);
    }

    public function setCookieShopCat() {
        $this->setCookieData('globe_shopcat', md5(time()));
    }

    public function getSlider() {

        $arySlider = array();

        $flag = $this->getDataFromSqlCache('flag_slider_cache');

        $flagCache = $flag[0];

        if ($flagCache == 0 && $this->checkSqlCacheFile('cache_slider') == true) {

            $arySlider = $this->getDataFromSqlCache('cache_slider');
        } else if ($flagCache == 1 || $this->checkSqlCacheFile('cache_slider') == false) {

            $intOk = $this->_objModule->getSliderData($arySlider);

            if ($intOk == 1) {
                $aryData = array('0' => 0);

                $this->buildSqlCache('flag_slider_cache', $aryData);

                $this->buildSqlCache('cache_slider', $arySlider);
            }
        }

        $this->assign('arySlider', $arySlider);
    }

    public function tintuc() {

//        $this->getSessionCustomer();
        $newsCategoryId = $this->getParamOnUrlByKey(1);

        if($newsCategoryId && preg_match("/page/", $newsCategoryId) == false){
            $this->filterVarId($newsCategoryId);
        }

        $aryCss = array();
        $aryCss[] = 'main.min.css';
        $aryCss[] = 'news.min.css';
        $aryCss[] = 'pagination.min.css';

//        $this->buildMenu();
//        $this->getSlider();

        $this->getRightProduct();

        $this->getTopViews();

        $this->getTopNew();

        $this->buildNewsCategory();

        $this->getBaogia();

        $aryConditions = array();

        if (isset($newsCategoryId) && is_numeric($newsCategoryId)) {

            $aryNewsParentCateogry = $this->builNewsParentCategory($newsCategoryId);

            $aryConditions['news_new_category_id'] = $newsCategoryId;
        } else {

            $aryConditions['news_new_category_id'] = 'trangchu';
        }

        $page = $this->getParam('page');

        if (!$page) {
            $page = 1;
        }else{
            $this->filterVarId($page);
        }

        $aryConditions['current_page'] = $page;

        $aryConfig = $this->getDataConfigFile('news_data_store');

        $limit = $aryConfig['config_news_in_home'];

        $aryConditions['record_per_page'] = $limit;

        $cacheNewsFile = 'tintuc_danhmuc_' . $aryConditions['news_new_category_id'] . '_trang_' . $page;

        $flagFile = $cacheNewsFile . '_flag';

        $flag = $this->getFlagCacheFile($flagFile);

        if ($flag == 0 && $this->checkSqlCacheFile($cacheNewsFile) == true) {

            $aryNewsData = $this->getDataFromSqlCache($cacheNewsFile);
        } else if ($flag == 1 || $this->checkSqlCacheFile($cacheNewsFile) == false) {

            $this->_objModule->getNewsData($aryConditions, $aryNewsData);

            $this->buildSqlCache($cacheNewsFile, $aryNewsData);
        }
//        print_r($aryNewsData);
        $this->resetFlagCacheFile($flagFile);

        $url = $_SERVER['REQUEST_URI'];

        $url = preg_replace('/\?page=([0-9]+)/', '', $url);

        $link = $url . '?page=';

        $strPaging = $this->pagination($link, $aryNewsData['paging']);
//        print_r($arySubCat);
        $this->assign('strPaging', $strPaging);
        $this->assign('aryNewsSubCategory', $arySubCat);
//        $this->assign('aryNewsParentCateogry', $aryNewsParentCateogry);
        $this->assign('newsCategoryId', $newsCategoryId);
//        $this->assign('aryNewsData', $aryNews);
//        $this->assign('aryFirtNews', $aryTopNews[0]);
//        unset($aryTopNews[0]);
        $this->assign('aryNewsData', $aryNewsData['data']);
//        print_r($aryNewsData);
//        $this->assign('aryTopTenNews', $aryTopTenNews);
//        $this->assign('aryProductCategory', $aryProductCategory);
        $this->assign('aryNewsParentCateogry', $aryNewsParentCateogry);

        if ($newsCategoryId) {
            if ($aryNewsParentCateogry[0]['news_category_title'] == '') {
                $strTitle = $aryNewsParentCateogry[0]['news_category_name'];
            } else {
                $strTitle = $aryNewsParentCateogry[0]['news_category_title'];
            }
            if ($aryNewsParentCateogry[0]['news_category_keywords'] == '') {
                $strKeyword = $aryNewsParentCateogry[0]['news_category_name'];
            } else {
                $strKeyword = $aryNewsParentCateogry[0]['news_category_keywords'];
            }
            if ($aryNewsParentCateogry[0]['news_category_description'] == '') {
                $strDescription = $aryNewsParentCateogry[0]['news_category_name'];
            } else {
                $strDescription = $aryNewsParentCateogry[0]['news_category_description'];
            }
        } else {
            $strTitle = $aryConfig['news_category_title'];
            $strKeyword = $aryConfig['news_category_keywords'];
            $strDescription = $aryConfig['news_category_description'];
        }
        $subDomain = $this->getSubDomain();
        $this->assign('urlImage', $subDomain['img'] . '/images/style/logo120x120.jpg');
        $this->assign('urlLink', $this->curUrl());
        $this->assign('title', $strTitle);
        $this->assign('keywords', $strKeyword);
        $this->assign('description', $strDescription);
        $this->assign('aryCss', $aryCss);
        $this->setViewTemplate('home', 'news_home');
    }

    public function buildNewsCategory() {

        $aryNewsCategory = array();

        $cacheFile = 'tintuc_home_menu';

        $flagFile = $cacheFile . '_flag';

        $flag = $this->getFlagCacheFile($flagFile);

        if ($flag == 0 && $this->checkSqlCacheFile($cacheFile) == true) {

            $aryNewsCategory = $this->getDataFromSqlCache($cacheFile);
        } else if ($flag == 1 || $this->checkSqlCacheFile($cacheFile) == false) {

            $this->_objModule->getNewsCategory($aryNewsCategory);

            foreach ($aryNewsCategory as $value) {
                if ($value['news_category_level'] == 0) {
                    $aryMainCat[] = $value;
                }
            }

            foreach ($aryNewsCategory as $value) {
                if ($value['news_category_level'] == 1) {
                    $arySubCat[$value['news_category_parent']] = $value;
                }
            }

            $this->buildSqlCache($cacheFile, $aryNewsCategory);

            $this->resetFlagCacheFile($flagFile);
        }

        $this->assign('aryNewsCategory', $aryNewsCategory);
    }

    public function tin() {

        $this->buildMenu();

        $newsCategoryId = $this->getParamOnUrlByKey(1);

        $aryNewsParentCateogry = $this->builNewsParentCategory($newsCategoryId);

        $this->_objModule->getProductCategoryInNews($newsCategoryId, $aryData);

        if (isset($aryData[0]['news_category_product_child_cat'])) {

            $listProductCategory = $aryData[0]['news_category_product_child_cat'];
        } else {

            $listProductCategory = 0;
        }

        $this->_objModule->getTopProduct(3, 10, $listProductCategory, $aryTopProduct);

        $this->_objModule->getTopProduct(1, 10, $listProductCategory, $aryNewsProduct);

        $limit = $this->getConfig('limit_news_by_news_cat');

        $this->_objModule->getNewByListNewsCategory($newsCategoryId, $limit, $aryNews);

        $this->assign('aryNewsFirst', $aryNews[0]);

        unset($aryNews[0]);

        $this->assign('aryNews', $aryNews);

        $this->assign('aryTopProduct', $aryTopProduct);

        $this->assign('aryNewsProduct', $aryNewsProduct);

        $this->_objModule->getProductCategory($aryProductCategory);

        $this->_objModule->getNewsTopViews(10, $aryNewsTopViews);

        $this->assign('aryTopViews', $aryNewsTopViews);

        $this->assign('aryProductCategory', $aryProductCategory);

        $this->assign('aryNewsParentCateogry', $aryNewsParentCateogry);

        foreach ($aryNewsParentCateogry as $key => $value) {
            $strTitle.= ' ' . $value['news_category_name'];
        }

        $this->assign('title', $strTitle . ' ' . $this->getConfig('title'));

        $this->setViewTemplate('news', 'news_by_category');
    }

    public function builNewsParentCategory($newsCategoryId) {

        $aryNewsParentCateogry = array();

        $cacheFile = 'tintuc_parent_of_danhmuc_' . $newsCategoryId;

        $flagFile = $cacheFile . '_flag';

        $flag = $this->getFlagCacheFile($flagFile);

        if ($flag == 0 && $this->checkSqlCacheFile($cacheFile) == true) {

            $aryNewsParentCateogry = $this->getDataFromSqlCache($cacheFile);
        } else if ($flag == 1 || $this->checkSqlCacheFile($cacheFile) == false) {

            $aryNewsCategory = $this->getDataFromSqlCache('tintuc_home_menu');

            $aryNewsParentCateogry = $this->findNewsParentPath($aryNewsCategory, $newsCategoryId);

            $this->buildSqlCache($cacheFile, $aryNewsParentCateogry);

            $this->resetFlagCacheFile($flagFile);
        }
        return $aryNewsParentCateogry;
    }

    public function findNewsParentPath($aryData, $subCatId) {
        $aryParent = array();
        foreach ($aryData as $value) {
            if ($value['news_category_id'] == $subCatId) {
                if ($value['news_category_parent'] != 0) {
                    $aryParent[] = $value;
                    $aryParent = array_merge($this->findNewsParentPath($aryData, $value['news_category_parent']), $aryParent);
                } else {
                    $aryParent[] = $value;
                }
            }
        }
        return $aryParent;
    }

    public function getTopViews() {

        $aryNewsTopViews = array();

        $cacheFile = 'tintuc_tin_xem_nhieu_nhat';

        $flagFile = $cacheFile . '_flag';

        $flag = $this->getFlagCacheFile($flagFile);

        if ($flag == 0 && $this->checkSqlCacheFile($cacheFile) == true) {

            $aryNewsTopViews = $this->getDataFromSqlCache($cacheFile);
        } else if ($flag == 1 || $this->checkSqlCacheFile($cacheFile) == false) {

            $aryConfig = $this->getDataConfigFile('news_data_store');

            $limit = $aryConfig['config_news_in_views'];

            $this->_objModule->getNewsTopViews($limit, $aryNewsTopViews);

            $this->buildSqlCache($cacheFile, $aryNewsTopViews);

            $this->resetFlagCacheFile($flagFile);
        }

        $this->assign('aryTopViews', $aryNewsTopViews);
    }

    public function getTopNew() {

        $aryTopNews = array();

        $cacheFile = 'tintuc_tin_moi_nhat';

        $flagFile = $cacheFile . '_flag';

        $flag = $this->getFlagCacheFile($flagFile);

        if ($flag == 0 && $this->checkSqlCacheFile($cacheFile) == true) {

            $aryTopNews = $this->getDataFromSqlCache($cacheFile);
        } else if ($flag == 1 || $this->checkSqlCacheFile($cacheFile) == false) {

            $aryConfig = $this->getDataConfigFile('news_data_store');

            $limit = $aryConfig['config_news_in_new'];

            $this->_objModule->getTopNews($aryTopNews, $limit);

            $this->buildSqlCache($cacheFile, $aryTopNews);

            $this->resetFlagCacheFile($flagFile);
        }
        $this->assign('aryTopNew', $aryTopNews);
    }

    public function chitiet() {

        $newsId = $this->getParamOnUrlByKey(1);

        $this->filterVarId($newsId);

        $aryCss = array();
        $aryCss[] = 'main.min.css';
        $aryCss[] = 'news.min.css';
        
        $this->buildNewsCategory();

        $this->getRightProduct();

        $this->getBaogia();

        $this->upadateTopNewsView($newsId);

        $cacheFile = 'tintuc_chi_tiet_' . $newsId;

        $flagFile = $cacheFile . '_flag';

        $flag = $this->getFlagCacheFile($flagFile);

        if ($flag == 0 && $this->checkSqlCacheFile($cacheFile) == true) {

            $aryNewsData = $this->getDataFromSqlCache($cacheFile);
        } else if ($flag == 1 || $this->checkSqlCacheFile($cacheFile) == false) {

            $this->_objModule->getNewsDetail($newsId, $aryNewsData);

            $this->buildSqlCache($cacheFile, $aryNewsData);

            $this->resetFlagCacheFile($flagFile);
        }

        $this->getTopViews();

        $this->getTopNew();

        $aryNews['news_title'] = $this->convertUnicode($aryNewsData[0]['news_title']);
        $aryNews['news_content'] = $this->convertUnicode($aryNewsData[0]['news_content']);
        $aryNews['news_updated_date'] = $aryNewsData[0]['news_updated_date'];

        $newsCategoryId = $aryNewsData[0]['news_new_category_id'];

        $this->builNewsParentCategory($newsCategoryId);

//        $this->assign('arySameNews', $aryNewsSameData);

        $this->assign('aryNews', $aryNews);
//        $this->assign('aryNewsParentCateogry', $aryNewsParentCateogry);
        //config keyword and title
        $this->assign('title', $aryNewsData[0]['news_title']);
        $this->assign('keywords', $aryNewsData[0]['news_title']);
        $this->assign('description', $aryNewsData[0]['news_content_filter']);
        $this->assign('urlLink', $this->curUrl());
        $subDomain = $this->getSubDomain();
        $this->assign('urlImage', $subDomain['img'] . '/images/upload/thumbnail/' . $aryNewsData[0]['news_main_image']);
        $this->assign('aryCss', $aryCss);
        $this->setViewTemplate('home', 'news_detail');
    }

    public function upadateTopNewsView($newsId) {

        $intOk = $this->_objModule->updateNewsViews($newsId);

        if ($intOk == 1) {
            $this->setFlagCacheFile('tin_xem_nhieu_nhat_flag');
        }
    }

    public function searchProduct() {

        $aryParam = $this->getAllPostParams();

        $aryResult = array();

        $aryConditions = array();

        $aryConditions['product_keyword'] = $this->encodingUnicode(strip_tags($aryParam['product_keyword']));

        $aryConditions['product_maker_id'] = $aryParam['product_maker'];

        $aryConditions['product_category_id'] = $aryParam['product_category_id'];

        if ($aryParam['product_price_from'] == '' || !is_numeric($aryParam['product_price_from'])) {

            $aryConditions['product_price_from'] = 0;
        } else if ($aryParam['product_price_from'] != '' && is_numeric($aryParam['product_price_from'])) {

            $aryConditions['product_price_from'] = $aryParam['product_price_from'];
        }

        if ($aryParam['product_price_to'] == '' || !is_numeric($aryParam['product_price_to'])) {

            $aryConditions['product_price_to'] = 0;
        } else if ($aryParam['product_price_to'] != '' && is_numeric($aryParam['product_price_to'])) {

            $aryConditions['product_price_to'] = $aryParam['product_price_to'];
        }

        $aryConditions['current_page'] = $this->getParam('page');

        $aryConditions['record_per_page'] = $this->getConfig('product_per_page');

        $intOk = $this->_objModule->searchProductData($aryConditions, $aryProduct);

        $this->assign('aryProduct', $aryProduct['data']);

        $this->setActionJSPaging("MyController.searchProduct(");

        $strPaging = $this->AjaxPagination($aryProduct['paging']);

        $this->assign('strPaging', $strPaging);

        $aryResult['intOk'] = $intOk;

        $aryResult['content'] = $this->getViewTemplate('home', 'product_search_result');

        echo json_encode($aryResult);
    }

    public function search() {

        $this->listSupportOnline();

        $this->getSessionCustomer();

        $this->buildMenu();

        $keyword = $this->getParam('keyword');

        $page = $this->getParam('page');

        $type = $this->getParam('type');

        $catId = $this->getParam('catId');

        $aryConditions = array();

        $aryConditions['keyword'] = $this->encodingUnicode(trim($keyword));

        $aryConditions['type'] = $type;

        if (isset($page) == false) {
            $page = 1;
        }

        $aryConditions['current_page'] = $page;

        $aryConditions['record_per_page'] = $this->getConfig('product_per_page');

        $aryConditions['product_category_id'] = $catId;

        $aryCategory = array();

        $aryProductSearch = array();

        $aryNewsResult = array();

        if (strlen($keyword) > 0) {

            $this->_objModule->searchCategoryInProduct($aryConditions, $aryCategoryProduct);

            foreach ($aryCategoryProduct as $key => $value) {
                $aryCategory[$value['product_category_id']]['product_category_name'] = $value['product_category_name'];
                $aryCategory[$value['product_category_id']]['product_category_id'] = $value['product_category_id'];
                $aryCategory[$value['product_category_id']]['product_category_total']++;
            }

            $this->_objModule->countTotalNews($aryConditions, $aryNewsResult);

            $countTotalNews = count($aryNewsResult);

            $aryPaging = array();

            $arySearchNews = array();

            if ($type == 'product' || $type == '') {

                $this->_objModule->searchAllProduct($aryConditions, $aryProductSearch);

                $aryPaging = $aryProductSearch['paging'];
            } else if ($type == 'news') {

                $this->_objModule->searchAllNews($aryConditions, $arySearchNews);

                $aryPaging = $arySearchNews['paging'];
            }
        }

        $url = $_SERVER['REQUEST_URI'];

        $url = preg_replace('/\&page=([0-9]+)/', '', $url);

        $url = preg_replace('/\.html/', '', $url);

        $link = $url . '&page=';

        $strPaging = $this->pagination($link, $aryPaging);

        $this->assign('type', $type);

        $this->assign('catId', $catId);

        $this->assign('keyword', $keyword);

        $this->assign('strPaging', $strPaging);

        $this->assign('countTotalNews', $countTotalNews);

        $this->assign('aryProductCategory', $aryCategory);

        $this->assign('aryProductSearch', $aryProductSearch['data']);

        $this->assign('arySearchNews', $arySearchNews['data']);

        $this->assign('title', 'Kết quả tìm kiếm ' . $keyword);

        $this->setViewTemplate('home', 'home_search_result');
    }

    public function productInfo() {

        $this->buildMenu();

        $productType = $this->getParamOnUrlByKey(1);

        switch ($productType) {
            case 1:
                $productTitle = "Sản phẩm mới";
                break;
            case 2:
                $productTitle = "Sản phẩm khuyến mại";
                break;
            case 3:
                $productTitle = "Sản phẩm bán chạy";
                break;
        }

        $categoryId = $this->getParamOnUrlByKey(2);

        $page = $this->getParam('page');

        if (isset($categoryId) && is_numeric($categoryId)) {

            $aryCategoryId = $this->_objModule->getCategoryChildPath($categoryId);

            array_push($aryCategoryId, $categoryId);

            $strCategory = implode(",", $aryCategoryId);

            $aryCategoryParent = $this->buildParentList($categoryId);

            $this->assign('categoryParent', $aryCategoryParent);

            if (is_array($aryCategoryParent)) {

                foreach ($aryCategoryParent as $key => $value) {

                    $strTitle.= $value['category_name'] . ' - ';
                }
            }
        }

        $aryConditions = array();

        $aryConditions['product_category_id'] = $strCategory;

        $aryConditions['product_type_id'] = $productType;

        $aryConditions['record_per_page'] = $this->getConfig('limit_product_info');

        $aryConditions['current_page'] = $page;

        $this->_objModule->getProductInfoByType($aryConditions, $aryProuctInfo);

        $this->assign('aryProduct', $aryProuctInfo['data']);



        $strTitle.=$productTitle;

        $this->assign('productTitle', $productTitle);

        $url = $_SERVER['REQUEST_URI'];

        $url = preg_replace('/\?page=([0-9]+)/', '', $url);

        $url = preg_replace('/\.html/', '', $url);

        $link = $url . '?page=';

        $strPaging = $this->pagination($link, $aryProuctInfo['paging']);

        $this->assign('strPaging', $strPaging);

        $this->assign('title', $strTitle);

        $this->assign('product_type', $productType);

        $this->setViewTemplate('home', 'product_list_product_info');
    }

    public function deleteAllOrder() {
        $cookieShopCat = $this->getCookieData('globe_shopcat');
        $aryConditions = array();
        $aryConditions['product_order_cookie_id'] = $cookieShopCat;
        $intOk = $this->_objModule->deleteAllShopCat($aryConditions);
        $aryResult = array();
        $aryResult['intOk'] = $intOk;
        $aryResult['shopContent'] = $this->getViewTemplate('home', 'product_shop_content');
        $aryResult['listOrder'] = $this->getViewTemplate('home', 'product_list_order');
        echo json_encode($aryResult);
    }

    public function deleteOrderById() {

        $orderId = $this->getPostParam('orderId');

        $aryDelete = array();

        $aryDelete['product_order_del_flag'] = 1;

        $aryConfig = array(
            array(
                'keyword' => 'where',
                'field' => 'product_order_id',
                'math' => '=',
                'value' => $orderId
            )
        );

        $intOk = $this->_objModule->deleteOrderById($aryDelete, $aryConfig);

        if ($intOk == 1) {

            $this->getProductOrder();
        }

        $aryResult = array();
        $aryResult['intOk'] = $intOk;
        $aryResult['shopContent'] = $this->getViewTemplate('home', 'product_shop_content');
        $aryResult['listOrder'] = $this->getViewTemplate('home', 'product_list_order');
        echo json_encode($aryResult);
    }

    public function setOrderProduct() {
        $orderType = $this->getPostParam('orderType');
        $this->setCookieData('order', $orderType);
    }

    public function getListProduct() {
        $listType = $this->getParam('listType');
        $value = $this->getParam('value');
        switch ($listType) {
            case "list":
                $this->setCookieData('listType', $value);
                break;
            case "order":
                $this->setCookieData('mct_order', $value);
                break;
        }
    }

    public function submitLink() {
        $aryParam = $this->getAllPostParams();
        $strError = '';
        $intOk = 0;
        $aryCustomer = $this->getSession('customer');
        $count = 0;
        $countLink = count($aryParam['item_link']);
        $aryResult = array();
        if ($aryCustomer['customer_id'] == '') {
            $aryResult['intOk'] = $intOk;
            $aryResult['strError'] = _CUSTOMER_NOT_LOGIN;
            echo json_encode($aryResult);
            return;
        }
        if ($aryCustomer['customer_id'] != '') {
            foreach ($aryParam['item_link'] as $key => $value) {
                if ($value['item_link'] == '') {
                    $count++;
                } else {
                    $aryCustomerLink = array();
                    $aryCustomerLink['mct_customer_link_link'] = $value;
                    $aryCustomerLink['mct_customer_link_customer_id'] = $aryCustomer['customer_id'];
                    $aryCustomerLink['mct_customer_link_product_id'] = $aryParam['product_id'];
                    $aryCustomerLink['mct_customer_link_send_date'] = date("Y-m-d H:i:s");
                    $intOk = $this->_objModule->saveCustomerLink($aryCustomerLink);
                }
            }
        }
        if ($count == $countLink) {
            $strError = _CUSTOMER_EMPTY_LINK;
        }
        $aryResult['intOk'] = $intOk;
        $aryResult['strError'] = $strError;
        $aryResult['messageSuccess'] = _CUSTOMER_SEND_LINK_SUCCESS;
        echo json_encode($aryResult);
    }

    public function getListSupportOnline() {
        $intOk = $this->_objModule->getSupportOnline($aryOnline);
        $this->assign('aryOnline', $aryOnline);
    }

    public function getSessionCustomer() {
        $aryCustomerInfo = $this->getSession('customer');
        $this->assign('sessionCustomer', $aryCustomerInfo);
    }

    public function logout() {
        $this->clearSession('customer');
        $this->redirectURL($this->_rootPage . "");
        $this->setViewTemplate('maccathue_new', 'logout');
    }

    public function commentsProduct() {

        $aryParam = $this->getAllPostParams();
        $aryError = array();
        $aryResult = array();
        $objValidate = new Validator();
        $flag = $objValidate->validateEmpty($aryParam['commentsTitle']);
        if ($flag == true) {
            $aryError['commentsTitle_error'] = 'Bạn chưa nhập tiêu đề.';
        } else {
            if ($aryParam['commentsTitle'] == 'Tiêu đề') {
                $aryError['commentsTitle_error'] = 'Bạn chưa nhập tiêu đề.';
            }
        }
        $flag = $objValidate->validateEmpty($aryParam['commentsFullName']);
        if ($flag == true) {
            $aryError['commentsFullName_error'] = 'Bạn chưa nhập họ tên.';
        } else {
            if ($aryParam['commentsFullName'] == 'Họ tên') {
                $aryError['commentsFullName_error'] = 'Bạn chưa nhập họ tên.';
            }
        }
        $flag = $objValidate->validateEmpty($aryParam['commentsEmail']);
        if ($flag == true) {
            $aryError['commentsEmail_error'] = 'Bạn chưa nhập địa chỉ Email.';
        } else {
            if ($aryParam['commentsEmail'] == 'Email') {
                $aryError['commentsEmail_error'] = 'Bạn chưa nhập địa chỉ email.';
            }
        }
        $flag = $objValidate->validateEmpty($aryParam['commentsContent']);
        if ($flag == true) {
            $aryError['commentsContent_error'] = 'Bạn chưa viết bình luận.';
        } else {
            if ($aryParam['commentsContent'] == 'Viết ý kiến của bạn') {
                $aryError['commentsEmail_error'] = 'Bạn chưa viết bình luận.';
            }
        }
        $flag = $objValidate->validateEmpty($aryParam['commentsCaptcha']);
        if ($flag == true) {
            $aryError['commentsCaptcha_error'] = 'Bạn chưa nhập mã an toàn.';
        } else {
            if (strtolower($aryParam['commentsCaptcha']) != $this->getSession('captcha')) {
                $aryError['commentsCaptcha_error'] = 'Mã an toàn không đúng.';
            }
        }
        if (count($aryError) > 0) {
            $aryResult['intOk'] = -2;
            $aryResult['aryError'] = $aryError;
            $aryResult['messageError'] = 'Vui lòng nhập đầy đủ thông tin trên.';
            echo json_encode($aryResult);
            return;
        }

        //$aryComments['comments_detail_id'] = $aryParam['comments_detail_id'];
        $aryComments['comments_detail_id'] = $aryParam['commentsId'];
        $aryComments['comments_title'] = $aryParam['commentsTitle'];
        $aryComments['comments_name'] = $aryParam['commentsFullName'];
        $aryComments['comments_email'] = $aryParam['commentsEmail'];
        $aryComments['comments_comments'] = $aryParam['commentsContent'];
        $aryComments['comments_datetime'] = date("YmdHis", time());
        $intOk = $this->_objModule->insertCommentsProduct($aryComments);

        $aryResult['intOk'] = $intOk;
        $aryResult['message'] = 'Yêu cầu của bạn đã được gửi.';
        echo json_encode($aryResult);
    }

    public function customerContact() {
        $aryParam = $this->getAllPostParams();
        $aryCustomer['customer_contact_title'] = $this->removeHTML($aryParam['customer_contact_title']);
        $aryCustomer['customer_contact_full_name'] = $this->removeHTML($aryParam['customer_contact_full_name']);
        $aryCustomer['customer_contact_email'] = $this->removeHTML($aryParam['customer_contact_email']);
        $aryCustomer['customer_contact_mobile'] = $this->removeHTML($aryParam['customer_contact_mobile']);
        $aryCustomer['customer_contact_address'] = $this->removeHTML($aryParam['customer_contact_address']);
        $aryCustomer['customer_contact_send_date'] = date('Y-m-d H:i:s');
        $aryCustomer['customer_contact_content'] = $this->removeHTML($aryParam['customer_contact_content']);
        $aryCustomer['customer_contact_content_filter'] = $this->cutString($aryParam['customer_contact_content']);
        $aryError = array();
        $objValidator = new Validator();
        $flag = $objValidator->validateEmpty($aryParam['customer_contact_title']);
        if ($flag == true) {
            $aryError['customer_contact_title_error'] = 'Bạn chưa nhập tiêu đề liên hệ.';
        }

        $flag = $objValidator->validateEmpty($aryParam['customer_contact_email']);
        if ($flag == true) {
            $aryError['customer_contact_email_error'] = 'Bạn chưa nhập địa chỉ Email.';
        } else {
            $flag = $objValidator->validateMail($aryParam['customer_contact_email']);
            if ($flag == false) {
                $aryError['customer_contact_email_error'] = 'Địa chỉ Email không chính xác.';
            }
        }
        $flag = $objValidator->validateEmpty($aryParam['customer_contact_mobile']);
        if ($flag == true) {
            $aryError['customer_contact_mobile_error'] = 'Bạn chưa nhập số điện thoại di động.';
        } else {
            $flag = $objValidator->validatePhone($aryParam['customer_contact_mobile']);
            if ($flag == false) {
                $aryError['customer_contact_mobile_error'] = 'Số điện thoại không chính xác.';
            }
        }
        $flag = $objValidator->validateEmpty($aryParam['customer_contact_address']);
        if ($flag == true) {
            $aryError['customer_contact_address_error'] = 'Bạn chưa nhập địa chỉ.';
        }
        $flag = $objValidator->validateEmpty($aryParam['customer_contact_content']);
        if ($flag == true) {
            $aryError['customer_contact_content_error'] = 'Bạn chưa nhập nội dung.';
        }
        $flag = $objValidator->validateEmpty($aryParam['customer_contact_full_name']);
        if ($flag == true) {
            $aryError['customer_contact_full_name_error'] = 'Bạn chưa nhập họ tên.';
        }

        $captcha = $this->getSession('captcha');
        if (strtolower($aryParam['captcha_code']) != $captcha) {
            $aryError['captcha_code_error'] = _CUSTOMER_ERROR_CAPTCHA;
        }
        $aryResult = array();
        if (count($aryError) > 0) {
            $aryResult['intOk'] = -2;
            $aryResult['aryError'] = $aryError;
            $aryResult['messageError'] = _CUSTOMER_MESSAGE_ERROR;
            echo json_encode($aryResult);
            return;
        }
        $intOk = $this->_objModule->saveCustomerContact($aryCustomer);
        $aryResult['intOk'] = 1;
        $aryResult['message'] = 'Thông tin liên hệ đã được gửi.';
        echo json_encode($aryResult);
    }

    public function getUserOnline() {
        $time = time();

        $time_check = $time - 300;

        if ($this->hasSession('time') == true) {

            $sessionTime = $this->getSession('time');

            if ($sessionTime < $time_check) {

                $this->setSession('time', $time);

                $aryData = array();

                $aryData = $this->_objModule->userOnline2();

                $this->buildSqlCache('user_online', $aryData);
            } else {

                $aryData = array();

                $aryData = $this->getDataFromSqlCache('user_online');
            }
        } else {

            $this->setSession('time', $time);

            $aryData = array();

            $aryData = $this->_objModule->userOnline2();

            $this->buildSqlCache('user_online', $aryData);
        }

        $this->assign('aryUserOnline', $aryData);
    }

    public function gioithieu() {
        $aryCss = array();
        $aryCss[] = "main.min.css";
        $this->buildMenu();
        $this->getSlider();
        $this->getRightProduct();
        $this->getBaogia();
        $type = 1;
        $intOk = $this->_objModule->getIntroductionData($type, $aryIntroduction);
        $this->assign('urlImage', $subDomain['img'] . '/images/style/logo120x120.jpg');
        $this->assign('urlLink', $this->curUrl());
        $this->assign('title', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('keywords', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('description', $this->cutString($aryIntroduction[0]['mc_company_common_content'], 250));
        $this->assign('aryIntroduction', $aryIntroduction[0]);
        $this->assign('aryCss', $aryCss);
        $this->setViewTemplate('home', 'introduction');
    }

    public function lienhe() {
        $aryCss = array();
        $aryCss[] = "main.min.css";
        $this->buildMenu();
        $this->getSlider();
        $this->getRightProduct();
        $this->getBaogia();
        $type = 4;
        $intOk = $this->_objModule->getIntroductionData($type, $aryIntroduction);
        $this->assign('urlImage', $subDomain['img'] . '/images/style/logo120x120.jpg');
        $this->assign('urlLink', $this->curUrl());
        $this->assign('title', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('keywords', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('description', $this->cutString($aryIntroduction[0]['mc_company_common_content'], 250));
        $this->assign('aryIntroduction', $aryIntroduction[0]);
        $this->assign('aryCss', $aryCss);
        $this->setViewTemplate('home', 'introduction');
    }

    public function dichvu() {
        $aryCss = array();
        $aryCss[] = "main.min.css";
        $this->buildMenu();
        $this->getSlider();
        $this->getRightProduct();
        $this->getBaogia();
        $type = 2;
        $intOk = $this->_objModule->getIntroductionData($type, $aryIntroduction);
        $this->assign('urlImage', $subDomain['img'] . '/images/style/logo120x120.jpg');
        $this->assign('urlLink', $this->curUrl());
        $this->assign('title', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('keywords', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('description', $this->cutString($aryIntroduction[0]['mc_company_common_content'], 250));
        $this->assign('aryIntroduction', $aryIntroduction[0]);
        $this->assign('aryCss', $aryCss);
        $this->setViewTemplate('home', 'introduction');
    }

    public function getBaogia() {
        $type = 3;
        $intOk = $this->_objModule->getBaogiaTitle($type, $aryBaogia);
        $this->assign('aryBaogia', $aryBaogia);
    }

    public function baogia() {
        $aryCss = array();
        $aryCss[] = "main.min.css";

        $param = $this->getParamOnUrlByKey(1);

        $param = $this->proccessParam($param);

        $this->buildMenu();
        $this->getSlider();
        $this->getRightProduct();
        $this->getBaogia();
        $intOk = $this->_objModule->getIntroductionByTitle($aryIntroduction, $param);
        $this->assign('urlImage', $subDomain['img'] . '/images/style/logo120x120.jpg');
        $this->assign('urlLink', $this->curUrl());
        $this->assign('title', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('keywords', $aryIntroduction[0]['mc_company_common_title']);
        $this->assign('description', $this->cutString($aryIntroduction[0]['mc_company_common_content'], 250));
        $this->assign('aryIntroduction', $aryIntroduction[0]);
        $this->assign('aryCss', $aryCss);
        $this->setViewTemplate('home', 'introduction');
    }

    public function getFooter() {
        $aryResult['content'] = $this->getViewTemplate('home', 'home_footer');
        echo $aryResult['content'];
    }


    
    /**
     * reedit database
     */
    //hàm để update lại DB fix lỗi tìm kiếm với Đ
    public function editData() {
        $sql = "SELECT product_id,
                        product_title FROM mc_product";
        $aryResultData = array();
        $intOk = $this->_objModule->getArray($sql, $aryResultData);

        if ($intOk == 1) {

            foreach ($aryResultData as $key => $value) {

                $aryConfig = array(
                    array(
                        'keyword' => 'where',
                        'field' => 'product_id',
                        'math' => '=',
                        'value' => $value['product_id']
                    )
                );

                $aryUpdate = array();
                $aryUpdate['product_title_search'] = $this->encodingUnicode($value['product_title']);
                $intOk = $this->_objModule->update('mc_product', $aryUpdate, $aryConfig);
            }
        }
        echo $intOk;
    }

    //hàm để thực hiện edit lại DB lọc keyword theo danh mục
    public function editCategoryKeyword() {
        $sql = "SELECT category_id,
                        category_name
                FROM mc_product_category ";
        $this->_objModule->getArray($sql, $aryResultData);
        foreach ($aryResultData as $key => $value) {
            $aryCategory[$key]['category_id'] = $value['category_id'];
            $category_keyword = str_replace(" -", "", $value['category_name']);
            $category_keyword = str_replace(" &", "", $category_keyword);
            $category_keyword = trim($category_keyword);
            $aryCategory[$key]['category_keyword'] = str_replace(" ", ",", $category_keyword);
        }

//        print_r($aryCategory);

        foreach ($aryCategory as $key => $value) {
            $aryConfig = array(
                array(
                    'keyword' => 'where',
                    'field' => 'category_id',
                    'math' => '=',
                    'value' => $value['category_id']
                )
            );

            $aryCategoryUpdate = array();
            $aryCategoryUpdate['category_keyword'] = $value['category_keyword'];

            $intOk = $this->_objModule->update('mc_product_category', $aryCategoryUpdate, $aryConfig);
        }

        echo $intOk;

        $this->setViewTemplate('news', 'news_detail');
    }

    //ham edit lại status show news category 1:show; 0:not show
    public function editShowNewCategory() {
        $sql = "UPDATE mc_news_category set news_category_is_show = 1";
        $intOk = $this->_objModule->Excute($sql);
        echo $intOk;
    }

    public function updateProductDB() {
        $sql = "SELECT product_id,
                        product_main_image,
                        product_small_image,
                        product_large_image
                    FROM mc_product ORDER BY product_id DESC";
        $intOk = $this->_objModule->getArray($sql, $aryData);
        foreach ($aryData as $key => $value) {
            $aryConfig = array(
                array(
                    'keyword' => 'where',
                    'field' => 'product_id',
                    'value' => $value['product_id'],
                    'math' => '='
                )
            );

            $aryUpdate = array();
            $aryUpdate['product_main_image'] = str_replace("/public/images/upload/thumbnail/", "", $value['product_main_image']);
            $aryUpdate['product_small_image'] = str_replace("/public/images/upload/small/", "", $value['product_small_image']);
            $aryUpdate['product_large_image'] = str_replace("/public/images/upload/large/", "", $value['product_large_image']);
            $intOk = $this->_objModule->update('mc_product', $aryUpdate, $aryConfig);
        }
    }

    public function updateProductCatDB() {
        $sql = "SELECT category_id,
                        category_main_image,
                        category_small_image
                    FROM mc_product_category";
        $intOk = $this->_objModule->getArray($sql, $aryData);
        foreach ($aryData as $key => $value) {
            $aryConfig = array(
                array(
                    'keyword' => 'where',
                    'field' => 'category_id',
                    'value' => $value['category_id'],
                    'math' => '='
                )
            );

            $aryUpdate = array();
            $aryUpdate['category_main_image'] = str_replace("/public/images/upload/thumbnail/", "", $value['category_main_image']);
            $aryUpdate['category_small_image'] = str_replace("/public/images/upload/small/", "", $value['category_small_image']);
            $intOk = $this->_objModule->update('mc_product_category', $aryUpdate, $aryConfig);
        }
    }

    public function updateNewsDB() {
        $sql = "SELECT news_id,
                        news_main_image,
                        news_large_image
                    FROM mc_news";
        $intOk = $this->_objModule->getArray($sql, $aryData);

        foreach ($aryData as $key => $value) {
            $aryConfig = array(
                array(
                    'keyword' => 'where',
                    'field' => 'news_id',
                    'value' => $value['news_id'],
                    'math' => '='
                )
            );

            $aryUpdate = array();
            $aryUpdate['news_main_image'] = str_replace("/public/images/upload/thumbnail/", "", $value['news_main_image']);
            $aryUpdate['news_large_image'] = str_replace("/public/images/upload/large/", "", $value['news_large_image']);
            $intOk = $this->_objModule->update('mc_news', $aryUpdate, $aryConfig);
        }
    }

    public function testLayout() {
        $this->setViewTemplate('home', 'test_layout');
    }

    public function testCarousel() {

        $aryProuductType = $this->getConfig('product_type');

        $aryProductByType = array();

        $ext = str_replace(",", "", $listCategory);


        foreach ($aryProuductType as $key => $value) {

            $this->_objModule->getProductByType($key, $aryProductByType[$key], $listCategory);
        }

        $this->buildSqlCache('product_by_type_cat_' . $ext, $aryProductByType);

        $this->assign('aryProductByType', $aryProductByType[1]);

//        print_r($aryProductByType);

        $this->assign('aryProductType', $aryProuductType);

        $this->setViewTemplate('home', 'test_carousel');
    }

    public function testScroller() {
        $this->setViewTemplate('home', 'test_carousel2');
    }

    public function testEffect() {
        $this->setViewTemplate('home', 'testEffect');
    }

    public function testZoom() {
        $this->setViewTemplate('home', 'testZoom');
    }

    public function loadQuickViewData() {
        $product_id = $this->getParam('product_id');
        $aryResult = array();
        $aryResult['success'] = 1;
        $aryResult['content'] = 'Product Id ' . $product_id;
        echo json_encode($aryResult);
    }

    public function testFlush() {
        $this->setViewTemplate('home', 'test-flush');
    }

}

?>
